From 7429347eb377666ae8a9f0583bb1d683b21c8d76 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 15 Jan 2017 01:14:47 +0300 Subject: [PATCH] More test for workspaces \w path dependencies --- tests/workspaces.rs | 104 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 51cb366c3..6d6be8a2d 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -1128,4 +1128,106 @@ fn path_dep_outside_workspace_is_not_member() { assert_that(p.cargo("build").cwd(p.root().join("ws")), execs().with_status(0)); -} \ No newline at end of file +} + +#[test] +fn test_in_and_out_of_workspace() { + let p = project("foo") + .file("ws/Cargo.toml", r#" + [project] + name = "ws" + version = "0.1.0" + authors = [] + + [dependencies] + foo = { path = "../foo" } + + [workspace] + members = [ "../bar" ] + "#) + .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }") + .file("foo/Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "../bar" } + "#) + .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }") + .file("bar/Cargo.toml", r#" + [project] + workspace = "../ws" + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/lib.rs", "pub fn f() { }"); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("ws")), + execs().with_status(0)); + + assert_that(&p.root().join("ws/Cargo.lock"), existing_file()); + assert_that(&p.root().join("ws/target"), existing_dir()); + assert_that(&p.root().join("foo/Cargo.lock"), is_not(existing_file())); + assert_that(&p.root().join("foo/target"), is_not(existing_dir())); + assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert_that(&p.root().join("bar/target"), is_not(existing_dir())); + + assert_that(p.cargo("build").cwd(p.root().join("foo")), + execs().with_status(0)); + assert_that(&p.root().join("foo/Cargo.lock"), existing_file()); + assert_that(&p.root().join("foo/target"), existing_dir()); + assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert_that(&p.root().join("bar/target"), is_not(existing_dir())); +} + +#[test] +fn test_path_dependency_under_member() { + let p = project("foo") + .file("ws/Cargo.toml", r#" + [project] + name = "ws" + version = "0.1.0" + authors = [] + + [dependencies] + foo = { path = "../foo" } + + "#) + .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }") + .file("foo/Cargo.toml", r#" + [project] + workspace = "../ws" + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "./bar" } + "#) + .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }") + .file("foo/bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("foo/bar/src/lib.rs", "pub fn f() { }"); + p.build(); + + assert_that(p.cargo("build").cwd(p.root().join("ws")), + execs().with_status(0)); + + assert_that(&p.root().join("foo/bar/Cargo.lock"), is_not(existing_file())); + assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir())); + + assert_that(p.cargo("build").cwd(p.root().join("foo/bar")), + execs().with_status(0)); + // Ideally, `foo/bar` should be a member of the workspace, + // because it is hierarchically under the workspace member. + assert_that(&p.root().join("foo/bar/Cargo.lock"), existing_file()); + assert_that(&p.root().join("foo/bar/target"), existing_dir()); +} -- 2.30.2